/*******************************************************************************
 * Copyright (c) 2015 btows.com.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package com.cleanwiz.applock.data.HideImageDao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import com.cleanwiz.applock.data.HideImage;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table HideImage.
*/
public class HideImageDao extends AbstractDao<HideImage, Long> {

    public static final String TABLENAME = "HideImage";

    /**
     * Properties of entity HideImage.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property BeyondGroupId = new Property(1, Integer.class, "beyondGroupId", false, "BEYOND_GROUP_ID");
        public final static Property Title = new Property(2, String.class, "title", false, "TITLE");
        public final static Property DisplayName = new Property(3, String.class, "displayName", false, "DISPLAY_NAME");
        public final static Property MimeType = new Property(4, String.class, "mimeType", false, "MIME_TYPE");
        public final static Property OldPathUrl = new Property(5, String.class, "oldPathUrl", false, "OLD_PATH_URL");
        public final static Property NewPathUrl = new Property(6, String.class, "newPathUrl", false, "NEW_PATH_URL");
        public final static Property Size = new Property(7, Long.class, "size", false, "SIZE");
        public final static Property MoveDate = new Property(8, Long.class, "moveDate", false, "MOVE_DATE");
    };


    public HideImageDao(DaoConfig config) {
        super(config);
    }
    
    public HideImageDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "'HideImage' (" + //
                "'_id' INTEGER PRIMARY KEY ," + // 0: id
                "'BEYOND_GROUP_ID' INTEGER," + // 1: beyondGroupId
                "'TITLE' TEXT," + // 2: title
                "'DISPLAY_NAME' TEXT," + // 3: displayName
                "'MIME_TYPE' TEXT," + // 4: mimeType
                "'OLD_PATH_URL' TEXT," + // 5: oldPathUrl
                "'NEW_PATH_URL' TEXT," + // 6: newPathUrl
                "'SIZE' INTEGER," + // 7: size
                "'MOVE_DATE' INTEGER);"); // 8: moveDate
    }

    /** Drops the underlying database table. */
    public static void dropTable(SQLiteDatabase db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'HideImage'";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, HideImage entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Integer beyondGroupId = entity.getBeyondGroupId();
        if (beyondGroupId != null) {
            stmt.bindLong(2, beyondGroupId);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(3, title);
        }
 
        String displayName = entity.getDisplayName();
        if (displayName != null) {
            stmt.bindString(4, displayName);
        }
 
        String mimeType = entity.getMimeType();
        if (mimeType != null) {
            stmt.bindString(5, mimeType);
        }
 
        String oldPathUrl = entity.getOldPathUrl();
        if (oldPathUrl != null) {
            stmt.bindString(6, oldPathUrl);
        }
 
        String newPathUrl = entity.getNewPathUrl();
        if (newPathUrl != null) {
            stmt.bindString(7, newPathUrl);
        }
 
        Long size = entity.getSize();
        if (size != null) {
            stmt.bindLong(8, size);
        }
 
        Long moveDate = entity.getMoveDate();
        if (moveDate != null) {
            stmt.bindLong(9, moveDate);
        }
    }

    /** @inheritdoc */
    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public HideImage readEntity(Cursor cursor, int offset) {
        HideImage entity = new HideImage( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // beyondGroupId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // title
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // displayName
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // mimeType
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // oldPathUrl
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // newPathUrl
            cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7), // size
            cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8) // moveDate
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, HideImage entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setBeyondGroupId(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
        entity.setTitle(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setDisplayName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setMimeType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setOldPathUrl(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setNewPathUrl(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setSize(cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7));
        entity.setMoveDate(cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8));
     }
    
    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(HideImage entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    /** @inheritdoc */
    @Override
    public Long getKey(HideImage entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}
